<template>
  <div class="cu-common-layout">
    <div class="cu-common-layout-center">
      <el-form @submit.native.prevent>
        <el-row class="cu-common-search-box" :gutter="16" style="display: flex; flex-wrap: wrap;">
          <el-col :span="6">
            <el-form-item label="校区品牌" prop="brand">
              <el-select v-model="query.brand" placeholder="" @change="handleChangeBrand" filterable clearable>
                <el-option :key="item.id" :label="item.fullName" :value="item.enCode" v-for="item in brandOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="校区名称">
              <el-select v-model="query.campusId" placeholder="校区名称" filterable clearable>
                <el-option v-for="(item, index) in campusOptions" :key="index" :label="item.fullName" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="闭校类别">
              <el-select v-model="query.type" placeholder="闭校类别" clearable>
                <el-option v-for="(item, index) in typeOptions" :key="index" :label="item.fullName" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <template v-if="showAll">
            <el-col :span="6">
              <el-form-item label="退还保证金">
                <el-select v-model="query.refundDeposit" placeholder="退还保证金" clearable>
                  <el-option v-for="(item, index) in refundDepositOptions" :key="index" :label="item.fullName" :value="item.id" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="退款时间">
                <el-date-picker v-model="query.refundDate" type="daterange" value-format="timestamp" format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="退款状态">
                <el-select v-model="query.refundStatus" placeholder="退款状态" clearable>
                  <el-option v-for="(item, index) in refundStatusOptions" :key="index" :label="item.fullName" :value="item.id" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="闭校时间">
                <el-date-picker v-model="query.closureDate" type="daterange" value-format="timestamp" format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
              </el-form-item>
            </el-col>
            <!--            <el-col :span="6">
              <el-form-item label="闭校说明">
                <el-input v-model="query.closureNotes" placeholder="闭校说明" />
              </el-form-item>
            </el-col>-->
          </template>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
              <el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
              <el-button type="text" icon="el-icon-arrow-down" @click="showAll = true" v-if="!showAll">展开</el-button>
              <el-button type="text" icon="el-icon-arrow-up" @click="showAll = false" v-else>收起</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="cu-common-layout-main cu-flex-main">
        <div class="cu-common-head">
          <div>
            <!--            <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">新增</el-button>-->
            <el-button type="text" icon="el-icon-download" @click="exportData()" v-has="'btn_download'">导出</el-button>
          </div>
          <div class="cu-common-head-right">
            <el-tooltip effect="dark" content="刷新" placement="top">
              <el-link icon="icon-ym icon-ym-Refresh cu-common-head-icon" :underline="false" @click="reset()" />
            </el-tooltip>
            <screenfull isContainer />
          </div>
        </div>
        <custom-table v-loading="listLoading" :data="list">
          <el-table-column label="校区名称" prop="campusId" align="left" width="200" show-overflow-tooltip>
            <template slot-scope="scope">
              {{ scope.row.campusId | dynamicText(campusOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="brand" label="校区品牌" align="center" width="80">
            <template slot-scope="scope">
              {{ scope.row.brand | dynamicCodeText(brandOptions) }}
            </template>
          </el-table-column>

          <el-table-column label="闭校类别" prop="type" align="left" show-overflow-tooltip>
            <template slot-scope="scope">
              {{ scope.row.type | dynamicText(typeOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="closureDate" label="闭校日期" align="center" width="100" :formatter="custom.tableDateFormat" />
          <el-table-column prop="closureNotes" label="闭校说明" align="left" show-overflow-tooltip />
          <el-table-column label="保证金审核" prop="refundDeposit" align="left" show-overflow-tooltip>
            <template slot-scope="scope">
              {{ scope.row.refundDeposit | dynamicText(refundDepositOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="expectedRefundAmount" label="保证金" align="left" />
          <el-table-column prop="refundAmount" label="退款金额" align="left" show-overflow-tooltip />
          <el-table-column prop="refundDate" label="退款日期" align="center" width="100" :formatter="custom.tableDateFormat" />
          <el-table-column label="退款状态" prop="refundStatus" align="left" show-overflow-tooltip>
            <template slot-scope="scope">
              {{ scope.row.refundStatus | dynamicText(refundStatusOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="refundNotes" label="退款说明" align="left" show-overflow-tooltip />
          <el-table-column prop="createTime" label="操作时间" align="center" width="120" :formatter="custom.tableDateTimeFormat"></el-table-column>
          <el-table-column prop="createUserName" label="操作人" align="center" width="80"></el-table-column>
          <el-table-column label="操作" fixed="right" width="120">
            <template slot-scope="scope">
              <el-button type="text" @click="addOrUpdateHandle(scope.row, false)">编辑</el-button>
              <el-dropdown @command="handleCommandDown" v-if="scope.row.attachments && scope.row.attachments.length > 0">
                <span class="el-dropdown-link">
                  <el-button type="text">下载</el-button>
                  <i class="el-icon-arrow-down el-icon--right"></i>
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item v-for="(item, index) in scope.row.attachments" :key="index" :command="item.url">{{ item.name }}</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </el-table-column>
        </custom-table>
        <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
      </div>
    </div>
    <custom-form v-if="formVisible" ref="CustomForm" @refresh="refresh" />
    <ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
  </div>
</template>
<script>
export { default } from './index.js'
</script>
